Skip to main content

20240525 2903 - Easy - Double Pointers

2903. Find Indices With Index and Value Difference I

class Solution:
def findIndices(self, nums: List[int], indexDifference: int, valueDifference: int) -> List[int]:
n = len(nums)
for i in range(n):
for j in range(i + indexDifference, n, 1):
if abs(nums[i] - nums[j]) >= valueDifference:
return [i, j]
return [-1, -1]